from machine import Pin, SPI
from e2in9 import EPD
import time
import framebuf
import ufont

# 定义引脚，初始化SPI
miso = Pin(12)
mosi = Pin(14)
sck = Pin(13)
cs = Pin(15)
dc = Pin(27)
rst = Pin(26)
busy = Pin(25)
spi = SPI(2, baudrate=10000000, polarity=0, phase=0, sck=sck, miso=miso, mosi=mosi)

# 创建墨水屏驱动对象，初始化屏幕
display = EPD(spi, cs, dc, rst, busy)


# 定义要展示的内容
f = ufont.BMFont("unifont-14-12917-16.v3.bmf")

# 显示文字,black = 0,white = 1
display.fill(1)
display.set_refresh(True)
f.text(display=display, string="测试Test", x=0, y=0, font_size=16, show=True, clear=True, reverse=True)
f.text(display=display, string="测试Test", x=0, y=16, font_size=24, show=True)
f.text(display=display, string="测试Test", x=0, y=40, font_size=32, show=True, reverse=True)
display.set_refresh(False)

